package com.gmall.console.system.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * <p>
 *
 * </p>
 *
 * @author Jone
 * @since 2024-05-30
 */
@TableName("T_MENU")
@Schema(name = "Menu", description = "")
@Data
public class Menu implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(description = "id")
    private Integer id;

    @Schema(description = "请求路径")
    private String path;

    @Schema(description = "接口路径")
    private String redirect;

    @Schema(description = "名称")
    private String name;

    @Schema(description = "标题")
    private String title;

    @Schema(description = "内容")
    private String component;

    @Schema(description = "图标")
    private String icon;

    @Schema(description = "父节点")
    private Integer parentId;

    @Schema(description = "是否有节点")
    private String isLeaf;

    @Schema(description = "是否隐藏")
    private Boolean hidden;

    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @Schema(description = "创建人")
    private String createBy;

    @Schema(description = "修改时间")
    private LocalDateTime updateTime;

    @Schema(description = "修改人")
    private String updateBy;

    //mybatis plus 匹配的时候会忽略
    @TableField(exist = false)
    //为空的时候不返回字段
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<Menu> children;

    @TableField(exist = false)
    private Map<String,Object> meta;

    public Map<String, Object> getMeta() {
        meta = new HashMap<>();
        meta.put("title",title);
        meta.put("icon",icon);
        return meta;
    }

}
